import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    //是否登录
    isLogin: false,
    // 用户id
    uid: '',
    //当前购物车数量
    shoppingCartNum:0
  },
  getters: {

  },
  mutations: {
    changeLogin(state, { code, sku }) {
      state.uid=sku.uid
      if (code == 200) { state.isLogin = true }
      localStorage.setItem("user", JSON.stringify(sku));
      
    },
    currentShoppingCartNum(state,num){
      // console.log(num);
      state.shoppingCartNum=num
    },
    changeShoppingCartNum(state,num){
      state.shoppingCartNum+=num

    }
    
    

  },
  actions: {


  },
  modules: {
  }
})
